home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 8_13.lha / 8_13 / tst13.c < prev    next >
Text File  |  1993-08-08  |  648b  |  34 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <pat.h>
  6.  
  7. ain()
  8.  
  9.    pat p(cin);
  10.    int x, y;
  11.    float f;
  12.  
  13.    if (p.match("%d %f %d")) {
  14. cout << "match 1 %d %f %d succeeded\n";
  15. p >> x >> f >> y;
  16.    } else if (p.match("%f %d %d")) {
  17. cout << "match 2 %f %d %d succeeded\n";
  18. p >> f >> x >> y;
  19.    } else {
  20. cout << "default succeeded\n";
  21. p >> x >> y >> f;
  22.    }
  23.  
  24.    cout << "x = " << x << "\n"
  25.  << "y = " << y << "\n"
  26.  << "f = " << f << "\n";
  27.  
  28.    int a = -1, b = -2;
  29.    p >> a >> b;
  30.    cout << "a = " << a << "\n"
  31.  << "b = " << b << "\n";
  32.    return 0;
  33.  
  34.